package xpn;

import com.querydsl.jpa.impl.JPAQueryFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import xpn.platform.common.config.XpnPlatformConfig;
import xpn.platform.common.repository.XpnRepositoryImpl;

import javax.persistence.EntityManager;

/**
 * Hello world!
 *
 */

@SpringBootApplication
@EnableScheduling
@EnableTransactionManagement // 允许事务管理
@EnableJpaAuditing // 允许审计功能
@EnableJpaRepositories(repositoryBaseClass = XpnRepositoryImpl.class) // 注册自定义的Repository
@EnableConfigurationProperties(XpnPlatformConfig.class) // 注册配置组件
public class App
{
    @Bean
    public JPAQueryFactory jpaQueryFactory(EntityManager entityManager){
        return new JPAQueryFactory(entityManager);
    }

    public static void main( String[] args )
    {
        SpringApplication.run(App.class, args);
    }
}
